<script type="text/x-template" id="cache-update-form">
    <div>
        <avue-form :option="updateCacheOption"
                   v-model="updateCacheOptionTableFormData"
                   @submit="handleUpdateCache">
        </avue-form>
    </div>
</script>

<script>
    //更新缓存信息-表单配置信息
    var updateCacheOption = {
        labelWidth: 120,
        menuPostion: 'right',
        submitText: '更新缓存',
        emptyBtn: false,
        column: [
            {
                label: '资源ID',
                prop: 'id',
                width: '120',
                'span': 24,
                rules: [{
                    required: true,
                    message: '请输入资源ID',
                    trigger: 'blur'
                }]
            },
            {
                label: '资源类型',
                prop: 'type',
                width: '120',
                'span': 24,
                valueDefault: 'pannel',
                rules: [{
                    required: true,
                    message: '请输入资源类型',
                    trigger: 'blur'
                }]
            }
        ]
    };
    Vue.component('cache-update-form', {
        template: '#cache-update-form',
        data() {
            return {
                updateCacheOption: {}, //更新缓存-表单设置属性
                updateCacheOptionTableFormData: {},//更新缓存-表单的数据
                isHomeDmpSwitcherOn:undefined,
                urls: {
                    updateCache: '/myCache/updateCache.html',
                }
            }
        },
        computed: {},
        methods: {
            /**
             * 更新缓存
             * @param form
             */
            handleUpdateCache: function (form) {
                var _this = this;
                this.$confirm('是否确认更新资源ID[' + form.id + ']的缓存！', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(function () {
                    _this.ajax(_this.urls.updateCache, {
                        id: form.id,
                        type: form.type
                    }, function (res) {
                        var data = res;
                        if (data.code === '0') {
                            _this.$message({
                                showClose: true,
                                message: '操作成功',
                                type: 'success'
                            })
                        } else {
                            _this.$message(data.msg);
                        }
                    });
                }).catch(function () {
                    _this.$message({
                        type: 'info',
                        message: '取消操作！'
                    });
                });
            },
        },
        mounted() {

        },
        created() {
            this.updateCacheOption = updateCacheOption;
        }
    })
</script>
<style>
    .select-option{
    div{
        width:200px;
    }
    }
</style>
